public  class Solution1 {
    public boolean chkPalindrome(ListNode A) {
        if(A==null&&A.next==null)
            return true;
        ListNode slow = A;
        ListNode fast = A;
        while(fast!=null&&fast.next!=null){
            fast=fast.next.next;
            slow=slow.next;
        }
        ListNode cur = slow.next;
        ListNode curN ;
        while(cur!=null){
            curN = cur.next;
            cur.next=slow;
            slow=cur;
            cur=curN;
        }
        ListNode first = A;
        while(first !=slow){
            if(first.val!=slow.val)
                return false;
            if(first.next==slow)
                return true;
            first = first.next;
            slow=slow.next;
        }
        return true;
    }
}
